<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div>
    <el-form ref="form" :model="t_item" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 设置人员 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="步骤" prop="">
              {{t_item.workName}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="选择人员" prop="assigned_id">
              {{t_item.assigned_id}}
              <el-button @click="popSelectionOfficerCurrency('assigned_id','assigned_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="开始时间" prop="start_time">
              {{getDateTimeString(t_item,'start_time')}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="结束时间" prop="end_time">
              {{getDateTimeString(t_item,'end_time')}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="settingPersonnelSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
    </el-form>
    <el-dialog :visible.sync="SelectionOfficerCurrencyVisible" append-to-body>
      <SelectionOfficerCurrency v-if="SelectionOfficerCurrencyVisible" ref="SelectionOfficerCurrency" :popparams="popparams"> </SelectionOfficerCurrency>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionOfficerCurrency from "@/views/mes/autooffice/SelectionOfficerCurrency";
  export default {
    name: 'SettingPersonnel',
    components: {
      SelectionOfficerCurrency,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionOfficerCurrencyVisible: false,
        SelectionOfficerCurrencyValue: null,
        SelectionOfficerCurrencyDesc: null,
        vueparams: this.getVUEParams(""),
        t_item: {
          workName: null,
          assigned_id: null,
          start_time: null,
          end_time: null,
        },
        loading: false,
        rules: {}
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/settingPersonnel?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      settingPersonnelSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/settingPersonnelSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.$router.replace("/redirect" + this.$route.fullPath);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popSelectionOfficerCurrency(desc, value) {
        this.SelectionOfficerCurrencyVisible = true;
        this.SelectionOfficerCurrencyDesc = desc;
        this.SelectionOfficerCurrencyValue = value;
      },
      closeSelectionOfficerCurrency(value, desc) {
        this.SelectionOfficerCurrencyVisible = false;
        this.$set(this.t_item, this.SelectionOfficerCurrencyDesc, desc);
        this.$set(this.t_item, this.SelectionOfficerCurrencyValue, value);
      },
    },
  }
</script>
